public class Main {
    public static int solution(String S, String T) {
        // PLEASE DO NOT MODIFY THE FUNCTION SIGNATURE
        // write code here
        int n = S.length();
        int m = T.length();
        int ans = n;
        int cnt = 0;

        for (int i = 0; i< Math.min(n, m); i++) {
            if (S.charAt(i) != T.charAt(i)){
                cnt++;
            }
            ans = Math.min(ans, cnt + n - 1 - i);

        }

        return ans;
    }

    public static void main(String[] args) {
        System.out.println(solution("aba", "abb") == 1);
        System.out.println(solution("abcd", "efg") == 4);
        System.out.println(solution("xyz", "xy") == 1);
        System.out.println(solution("hello", "helloworld") == 0);
        System.out.println(solution("same", "same") == 0);
    }
}